<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="设备序列号" prop="FSERNU">
            <el-input v-model="dataForm.FSERNU"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="固定资产码" prop="FACCNO">
            <el-input v-model="dataForm.FACCNO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="设备状态">
              <el-select v-model="dataForm.FSTATE" placeholder="请选择" >
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="智能柜名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="存储分类">
              <el-select v-model="dataForm.FCLASS" placeholder="请选择">
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="标签类型">
              <el-select v-model="dataForm.FLABEL" placeholder="请选择">
                <el-option
                  v-for="item in options5"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="教学楼">
              <el-select v-model="dataForm.FGROUP" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="楼层">
              <el-select v-model="dataForm.FLEVEL" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="场地名称">
              <el-select v-model="dataForm.FPOINT" placeholder="请选择">
                <el-option
                  v-for="item in options6"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        
        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="仓门列表" name="first">
        <el-table :data="list" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FSERNU" label="序列号" ></el-table-column>
          <el-table-column prop="FACCNO" label="固定资产码"></el-table-column>
          <el-table-column prop="FCATNAME" label="储物仓名称" ></el-table-column>
          <el-table-column prop="FMEMO" label="备注" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

      <el-tab-pane label="IOT控制" name="second">
        <el-row class="JNPF-common-search-box" :gutter="16">
        <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
          
          <el-col :span="8">
          <el-form-item label="控制器-IP" prop="FIP">
            <el-input v-model="dataForm.FIP"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="控制器-PORT" prop="FPORT">
            <el-input v-model="dataForm.FPORT"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="指示灯开" prop="FLIGHT">
            <el-input v-model="dataForm.FLIGHT"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="蜂鸣器灯开" prop="FWARRINGON">
            <el-input v-model="dataForm.FWARRINGON"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="蜂鸣器灯关" prop="FWARRINGOFF">
            <el-input v-model="dataForm.FWARRINGOFF"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="是否有风机" prop="FFLAG1">
            <el-checkbox v-model="checked1"></el-checkbox>
         </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="是否有VOC传感器" prop="FFLAG2">
            <el-checkbox v-model="checked2"></el-checkbox>
         </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="是否有温度传感器" prop="FFLAG3">
            <el-checkbox v-model="checked3"></el-checkbox>
         </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="是否有湿度传感器" prop="FFLAG4">
            <el-checkbox v-model="checked4"></el-checkbox>
         </el-form-item>
        </el-col>

        
         </el-form>
        </el-row>

      </el-tab-pane>
      
    </el-tabs>
  </template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        checked1: true,
        checked2: true,
        checked3: true,
        checked4: true,
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
            FSERNU:"BAE684FF8821TGH5",
            FACCNO:"SHYL0002",
            FCATNAME:"测试RFID柜-2",
            FCLASS:"易制毒",
            FLABEL:"RFID柜",
            FGROUP:"第一教学楼",
            FLEVEL:"二楼",
            FPOINT:"奉化学楼202",
            FSTATE:"正常"
        },
        rules: {
          FSERNU:[
            { required: true, message: '请输入设备序列号', trigger: 'blur' },
          ],
          FACCNO: [
            { required: true, message: '请输入固定资产码', trigger: 'blur' },
          ],
          FCATNAME: [
            { required: true, message: '请输入智能柜名称', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FSERNU":"ADE684FF8821TGH1",
                  "FACCNO":"CMYL0001",
                  "FCATNAME":"1-1仓",
                  "FMEMO":""
                },
                { "FENTRYID":2,
                  "FSERNU":"ADE684FF8821TGH2",
                  "FACCNO":"CMYL0002",
                  "FCATNAME":"1-2仓",
                  "FMEMO":""
                },
                { "FENTRYID":3,
                  "FSERNU":"ADE684FF8821TGH3",
                  "FACCNO":"CMYL0003",
                  "FCATNAME":"2-1仓",
                  "FMEMO":""
                },
                { "FENTRYID":4,
                  "FSERNU":"ADE684FF8821TGH4",
                  "FACCNO":"CMYL0004",
                  "FCATNAME":"2-2仓",
                  "FMEMO":""
                }],

        loading: false,
        visible: false,

        //所属教学楼选择数据
        options1: [{
          value: '20E01',
          label: '第一教学楼'
        }, {
          value: '20E02',
          label: '第二教学楼'
        }, {
          value: '20N01',
          label: '化学楼'
        }, {
          value: '20N02',
          label: '综合实验楼'
        }],

        //所属楼层选择数据
        options2: [{
          value: '20E01',
          label: '一楼'
        }, {
          value: '20E02',
          label: '二楼'
        }, {
          value: '20N01',
          label: '三楼'
        }, {
          value: '20N02',
          label: '四楼'
        }],

        //
        options3: [{
          value: '20E01',
          label: '正常'
        }, {
          value: '20E02',
          label: '维修'
        }, {
          value: '20N01',
          label: '保养'
        }, {
          value: '20N02',
          label: '停用'
        }],

        options4: [{
          value: '1',
          label: '易制毒'
        }, {
          value: '2',
          label: '易制爆'
        }, {
          value: '3',
          label: '一般化学品'
        }, {
          value: '4',
          label: '剧毒品'
        }, {
          value: '5',
          label: '危险化学品'
        }],

        options5: [{
          value: '1',
          label: 'RFID柜'
        }, {
          value: '2',
          label: '二维码柜'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>